package cn.liyiming.bbs.modular.system.controller;

import cn.liyiming.bbs.modular.system.model.Comment;
import cn.liyiming.bbs.modular.system.service.impl.CommentServiceImpl;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thymeleaf.engine.DataDrivenTemplateIterator;

import java.util.Date;

/**
 * @program: bbsblog
 * @description: 文章评论
 * @author: 李一鸣
 * @create: 2020-03-27 17:45
 **/
@Controller
@RequestMapping("/comment")
public class CommentController extends BaseController {

    @Autowired
    private CommentServiceImpl commentService;

    @RequestMapping("/save")
    @ResponseBody
    public Object saveComment(Comment comment) {
        if (comment != null && comment.getComContent() != "") {
            comment.setComTime(new Date());
            commentService.saveComment(comment);
        } else {
            return ResponseData.error("评论内容不能为空");
        }
        return ResponseData.success();
    }


}
